const baseaUrl = "https://www.forerunnercollege.com/soApi/"

export default function(url: string, data: {}, method: "POST" | "GET" = "POST") {
	return new Promise((relove, reject) => {
		const token=uni.getStorageSync("token")
		uni.request({
			url: `${baseaUrl}${url}`,
			method,
			data,
			header: {
				// 异步请求，如果是json，需要自己加上 Content-type
				'Content-type': 'application/json',
				'Authorization':token
			},
			// 成功后的回调函数
			success(res) {
				relove(res)
			},
			fail(res) {
				uni.showToast({
					title:"网络错误",
					icon:"error"
				})
				reject(res)
			}
		})
	})

}